package com.wyzt.common.advice;

import com.wyzt.common.exception.WyztException;
import com.wyzt.common.vo.ExceptionResult;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice
public class CommonExceptionHandler {

    //拦截controller异常，处理结果
    @ExceptionHandler(WyztException.class)
    public ResponseEntity<ExceptionResult> handleException(WyztException e) {
        return ResponseEntity
                .status(e.getExceptionEnum().getCode())
                .body(new ExceptionResult(e.getExceptionEnum()));
    }


}
